# -*- coding: utf-8 -*-
# @Time : 2024/3/7 17:22
# @Author : ZH
# @File : 46.py
# @Software: PyCharm
class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        res = []
        def sss(path, used):
            if len(path) == len(nums):
                res.append(list(path))
            for i in range(len(nums)):
                if used[i]:
                    continue
                path.append(nums[i])
                used[i] = True
                sss(path, used)
                path.pop()
                used[i] = False
        sss([], [False] * len(nums))
        return res

